﻿package mortal.game.view.lookPlayerInfo.view
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.lookPlayerInfo.*;
    import mortal.game.view.palyer.data.*;
    import mortal.game.view.wizard.panel.*;

    public class LookSystemEquipPart extends GSprite
    {
        private var _mountItemSp:GSprite;
        private var _grouthOpenTips:GTextFiled;
        private var _talentItemTips:GTextFiled;
        private var _mountGrouthItem:BaseItem;
        private var _mountSharpItem:OtherEquipItem;
        private var _mountTalentItem:BaseItem;
        private var _equipMentList:Vector.<OtherEquipItem>;
        private var _slookMountInfo:SLookPlayerMountInfo;
        protected var _tmountInfo:TMountConfig;
        private var _lookType:int;

        public function LookSystemEquipPart()
        {
            this._equipMentList = new Vector.<OtherEquipItem>;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatDanLan;
            _loc_1.size = 13;
            this._mountItemSp = UICompomentPool.getUICompoment(GSprite);
            this._mountItemSp.x = 0;
            this._mountItemSp.y = 0;
            this.addChild(this._mountItemSp);
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.MountEquipBg, 0, 0, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.MountEquipBg, 400, 0, this));
            this.addSharpItem();
            this.createEquipList();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._mountItemSp.dispose(param1);
            this._mountItemSp = null;
            this._mountGrouthItem.dispose(param1);
            this._mountGrouthItem = null;
            this._mountTalentItem.dispose(param1);
            this._mountTalentItem = null;
            if (this._mountSharpItem)
            {
                this._mountSharpItem.dispose(param1);
                this._mountSharpItem = null;
            }
            this._equipMentList.length = 0;
            if (this._grouthOpenTips)
            {
                this._grouthOpenTips.dispose(param1);
                this._grouthOpenTips = null;
            }
            if (this._talentItemTips)
            {
                this._talentItemTips.dispose(param1);
                this._talentItemTips = null;
            }
            this._tmountInfo = null;
            this._slookMountInfo = null;
            super.disposeImpl(param1);
            return;
        }// end function

        protected function addSharpItem() : void
        {
            this._mountSharpItem = UICompomentPool.getUICompoment(OtherEquipItem);
            this._mountSharpItem.isSHowQuality = false;
            this._mountSharpItem.isShowColorBg = false;
            this._mountSharpItem.doubleClickEnabled = true;
            this._mountSharpItem.setItemStyle(ItemStyleConst.Small, ImagesConst.PrescriptionEquipBg, 10, 13);
            this._mountSharpItem.x = 13;
            this._mountSharpItem.y = -83;
            this._mountSharpItem.pos = 4;
            this._mountItemSp.addChild(this._mountSharpItem);
            return;
        }// end function

        protected function addTalentItem() : void
        {
            this._mountTalentItem = UICompomentPool.getUICompoment(BaseItem);
            this._mountTalentItem.isSHowQuality = false;
            this._mountTalentItem.isShowColorBg = false;
            this._mountTalentItem.setItemStyle(ItemStyleConst.Small, ImagesConst.FashionEquipBg, 9, 9);
            this._mountTalentItem.itemData = new ItemData(LookPlayerUtil.getTalentItemCode(this._lookType));
            this._mountTalentItem.x = 410;
            this._mountTalentItem.y = 152;
            this._mountItemSp.addChild(this._mountTalentItem);
            return;
        }// end function

        protected function addGrouthItem() : void
        {
            this._mountGrouthItem = UICompomentPool.getUICompoment(BaseItem);
            this._mountGrouthItem.isSHowQuality = false;
            this._mountGrouthItem.isShowColorBg = false;
            this._mountGrouthItem.setItemStyle(ItemStyleConst.Small, ImagesConst.FashionEquipBg, 9, 9);
            this._mountGrouthItem.itemData = new ItemData(LookPlayerUtil.getGrouthItemCode(this._lookType));
            this._mountGrouthItem.x = 8;
            this._mountGrouthItem.y = 152;
            this._mountItemSp.addChild(this._mountGrouthItem);
            return;
        }// end function

        protected function createEquipList() : void
        {
            var _loc_1:OtherEquipItem = null;
            var _loc_2:int = 0;
            while (_loc_2 < 4)
            {
                
                _loc_1 = UICompomentPool.getUICompoment(OtherEquipItem);
                _loc_1.setItemStyle(ItemStyleConst.Small, ImagesConst.EquipItemBg, 7, 7);
                _loc_1.isShowLock = true;
                _loc_1.x = 400 * (_loc_2 % 2) + 11;
                _loc_1.y = 60 * int(_loc_2 / 2) + 25;
                _loc_1.doubleClickEnabled = true;
                _loc_1.pos = _loc_2;
                this.pushUIToDisposeVec(_loc_1);
                this._equipMentList.push(_loc_1);
                this.addChild(_loc_1);
                _loc_2++;
            }
            if (this._mountSharpItem)
            {
                this._equipMentList.push(this._mountSharpItem);
            }
            return;
        }// end function

        protected function updateEquip() : void
        {
            var _loc_1:ItemData = null;
            var _loc_2:OtherEquipItem = null;
            var _loc_3:int = 0;
            while (_loc_3 < 4)
            {
                
                _loc_2 = this._equipMentList[_loc_3];
                _loc_2.isShowLock = false;
                _loc_2.itemData = new ItemData(LookPlayerUtil.getEquipItemCode(this._lookType, _loc_3));
                _loc_2.midLabel = LookPlayerUtil.getEquipTxt(this._lookType, _loc_3);
                _loc_2.bitmapEnable = false;
                _loc_2.setColorBg(0);
                _loc_2.clearStrengInfo();
                _loc_3++;
            }
            if (this._mountSharpItem)
            {
                this._mountSharpItem.itemData = null;
                this._mountSharpItem.midLabel = Language.getString(35337);
            }
            var _loc_4:* = this._slookMountInfo.playerItems;
            var _loc_5:* = _loc_4.length;
            _loc_3 = 0;
            while (_loc_3 < _loc_5)
            {
                
                _loc_1 = new ItemData(_loc_4[_loc_3]);
                if (_loc_1)
                {
                    if (_loc_1.itemInfo.type == EEquipMount._EEquipMountShape)
                    {
                        if (this._slookMountInfo.shape != _loc_1.itemCode)
                        {
                            ;
                        }
                    }
                    _loc_2 = this._equipMentList[_loc_1.itemInfo.type];
                    _loc_2.isShowLock = true;
                    _loc_2.itemData = _loc_1;
                    _loc_2.midLabel = "";
                    _loc_2.bitmapEnable = true;
                    _loc_2.updateStrengLevel(_loc_1.itemInfo.itemLevel);
                }
                _loc_3++;
            }
            return;
        }// end function

        public function setLookInfo(param1:SLookPlayerMountInfo, param2:int) : void
        {
            var _loc_4:GrowthTalentConsumeData = null;
            this._slookMountInfo = param1;
            this._lookType = param2;
            this._tmountInfo = MountConfig.instance.getMountInfoByCode(this._slookMountInfo.code, LookPlayerUtil.getConfigTypeByLookType(this._lookType));
            var _loc_3:* = this._slookMountInfo.code;
            this.addTalentItem();
            this.addGrouthItem();
            _loc_4 = new GrowthTalentConsumeData();
            _loc_4.hasUseNum = this._slookMountInfo.growth;
            _loc_4.currMaxNum = this._tmountInfo.maxUseGrowth;
            this._mountGrouthItem.itemData.extData = _loc_4;
            if (_loc_3 >= 4)
            {
                this._mountGrouthItem.enabled = true;
                if (this._grouthOpenTips)
                {
                    this._grouthOpenTips.dispose();
                    this._grouthOpenTips = null;
                }
            }
            else
            {
                this._mountGrouthItem.enabled = false;
                if (this._grouthOpenTips == null)
                {
                    this._grouthOpenTips = UIFactory.gTextField(Language.getString(35338), this._mountGrouthItem.x + 3, this._mountGrouthItem.y + 57, 80, 20, this, GlobalStyle.textFormatHui);
                }
            }
            _loc_4 = new GrowthTalentConsumeData();
            _loc_4.hasUseNum = this._slookMountInfo.talent;
            _loc_4.currMaxNum = this._tmountInfo.maxUseTalent;
            this._mountTalentItem.itemData.extData = _loc_4;
            if (_loc_3 >= 5)
            {
                this._mountTalentItem.enabled = true;
                if (this._talentItemTips)
                {
                    this._talentItemTips.dispose();
                    this._talentItemTips = null;
                }
            }
            else
            {
                this._mountTalentItem.enabled = false;
                if (this._talentItemTips == null)
                {
                    this._talentItemTips = UIFactory.gTextField(Language.getString(35339), this._mountTalentItem.x + 3, this._mountTalentItem.y + 57, 80, 20, this, GlobalStyle.textFormatHui);
                }
            }
            this.updateEquip();
            return;
        }// end function

    }
}
